package graph.geometricshapes
{
	public class GeometricRoundedRectangle extends GeometricRectangle implements IRounded
	{
		public static const NAME:String = "GeometricRoundedRectangle";
		public override function get getName():String
		{
			return NAME;
		}
		
		public static const DefaultCornerRadius:Number = 5;
		protected var _cornerRadius:Number = DefaultCornerRadius;
		public function get cornerRadius():Number
		{
			return this._cornerRadius;
		}
		public function set cornerRadius(value:Number):void
		{
			if (value < 0)
			{
				throw new ArgumentError("Error while setting " + this.getName + " corner radius value ( " + value.toString() + " )!");
			}
			this._cornerRadius = value;
		}
		
		public function GeometricRoundedRectangle(width:Number=DefaultWidth, height:Number=DefaultHeight, cornerRadius:Number = DefaultCornerRadius)
		{
			super(width, height);
			this.cornerRadius = cornerRadius;
		}
		
		public override function getArea():Number
		{
			var result:Number = super.getArea() - Math.pow(cornerRadius,2) * Math.PI;
			return result;
		}
		
		public override function getPerimeter():Number
		{
			var result:Number = super.getPerimeter() - (4 * cornerRadius) + (2 * Math.PI * cornerRadius);
			return result;
		}
	}
}